<?php
namespace app\common\model;

use app\extra\ApiToken;
use app\extra\BaseModel;
use app\extra\DBCont;

class SearchTag extends BaseModel
{
    use \think\model\concern\SoftDelete;
    protected $deleteTime = 'delete_time';
    protected $auto = ['user_id','auth'];
    // 标签
    public function setTagsAttr($value){
        return serializeByArray($value);
    }
    public function getTagsAttr($value){
        return unSerializeByJson($value);
    }
    public function setUserIdAttr()
    {
        return getUserID();
    }
    public function setAuthAttr($value){
        if (!empty($value)){
            return $value;
        }
        $name = getUserName();
        return  empty($name)? '匿名作者' : $name;
    }
    /**
     * 添加额外参数
     * @param $item
     */
    public function setAddedField(&$item){
        $item['user_desc'] = model('Admin')->getUserName($item['user_id']);
    }

}